package com.teemor.blog.controller;

import com.teemor.blog.api.IFootprintApiService;
import com.teemor.blog.bean.condition.TbFootprintCondition;
import com.teemor.blog.bean.dto.input.footprint.AddFootprintIPo;
import com.teemor.blog.bean.dto.input.footprint.QryFootprintsIPo;
import com.teemor.blog.bean.dto.input.footprint.UpdFootprintIPo;
import com.teemor.blog.bean.dto.output.footprint.QryFootprintOPo;
import com.teemor.blog.bean.dto.output.footprint.QryFootprintsOPo;
import com.teemor.blog.bean.entity.TbFootprint;
import com.teemor.blog.service.IFootprintService;
import java.util.List;

import com.teemor.common.bean.utils.BeanConvertor;
import io.swagger.models.auth.In;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author: zhoulk
 * @Description: 原子服务API接口实现
 * @date: 2020/03/22 10:55:25
 */
@RestController
public class FootprintController implements IFootprintApiService {
    @Autowired
    private IFootprintService iFootprintService;

    @Override
    public int countFootprint(@RequestBody QryFootprintsIPo inParam) {
        TbFootprintCondition condition = BeanConvertor.convertBean(inParam, TbFootprintCondition.class);
        return iFootprintService.countFootprint(condition);
    }

    @Override
    public List<QryFootprintsOPo> qryFootprints(@RequestBody QryFootprintsIPo inParam) {
        TbFootprintCondition condition = BeanConvertor.convertBean(inParam, TbFootprintCondition.class);
        return BeanConvertor.convertBeanList(iFootprintService.qryFootprints(condition), QryFootprintsOPo.class);
    }

    @Override
    public void addFootprint(@RequestBody AddFootprintIPo inParam) {
        TbFootprint tbFootprint = BeanConvertor.convertBean(inParam, TbFootprint.class);
        iFootprintService.addFootprint(tbFootprint);
    }
}